/* GUI CONVERTED from rccupu1.p (converter v1.75) Tue Apr 10 12:04:10 2001 */
/* rccupu1.p - CUSTOMER SCHEDULES - SWITCH TO SHIP-FROM DATABASE              */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.4.2.4 $                                                         */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3      LAST MODIFIED: 08/25/95   BY: BCM *G0TB*                */
/* REVISION: 8.5      LAST MODIFIED: 09/26/97   BY: *J21M* Suresh Nayak       */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 11/03/99   BY: *N05R* B. Gates           */
/* REVISION: 9.1      LAST MODIFIED: 01/21/00   BY: *J3NH* Ashwini G.         */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* $Revision: 1.4.2.4 $    BY: Jean Miller    DATE: 03/22/01 ECO: *P008*        */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/*************************************************************************
 * This routine handles database manipulation required for
 * centralized scheduled order processing, then calls rccupu2.p to
 * perform the inventory database transaction history updates.
 *************************************************************************/

{mfdeclre.i}

/* REPLACED NULLSTREAM BY BUFFER-COPY STATEMENT */
define input  parameter    sod_recno    as recid.
define input  parameter    central-db   like global_db.
define input  parameter    remarks      as character format "x(24)".
define input  parameter    cust         like so_cust.
define input  parameter    cum-ship-start-dt as date.

define input parameter l_int_time as integer no-undo.
define input  parameter    l_new_cum_qty like sod_cum_qty[1] no-undo.
define input-output parameter    undo_upu1    as logical.

define new shared workfile work_sod_det no-undo like sod_det.

define            variable err-flag       as integer.
define            variable change-db      as logical.

find sod_det where recid(sod_det) = sod_recno.

/* FIND OUT IF WE NEED TO CHANGE DATABASES */
find si_mstr where si_site = sod_site no-lock.

change-db = (si_db <> central-db).

/* IF NOT CONNECTED, ISSUE ERROR AND UNDO */
if change-db
   and not connected(si_db)
then do:
   /* Record not updated. Database not connected */
   {pxmsg.i &MSGNUM=2517 &ERRORLEVEL=4 &MSGARG1=si_db}
   return.
end.

if change-db then do:

   create work_sod_det.
   buffer-copy sod_det to work_sod_det .

   if recid(work_sod_det) = -1 then.

   /* Switch to the Inventory site */
   /* QUALIFIED  FIRST PARAMETER  WITH SOD_DET. */
   {gprun.i ""gpalias2.p"" "(sod_det.sod_site, output err-flag)" }
/*GUI*/ if global-beam-me-up then undo, leave.


   /* COPY CHANGES TO SHIP-FROM DATABASE SOD_DET */
   {gprun.i ""rcrsdupa.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


end.

/* Start a new routine which will use the inventory db alias,
 * create the required transaction history */
{gprun.i ""rccupu2.p""
   "(input sod_det.sod_nbr,
     input sod_det.sod_line,
     input remarks,
     input cust,
     input cum-ship-start-dt,
     input l_int_time,
     input l_new_cum_qty)"}
/*GUI*/ if global-beam-me-up then undo, leave.


/* CHANGE BACK TO CENTRAL ORDERING DATABASE */
if change-db then do:
   /* And finally, switch the database alias back to the
   *  scheduled order db */
   {gprun.i ""gpalias3.p"" "( input central-db, output err-flag)" }
/*GUI*/ if global-beam-me-up then undo, leave.

end.

undo_upu1 = false.
